<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--教练--%>
<%
    String path3 = request.getContextPath();
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <style type="text/css">
        li span {
            margin-left: 0px;
            cursor: pointer;
        }

        li span:hover {
            color: #427dff
        }

        .modal-data1 {
            visibility: hidden;
            z-index: 1001;
            width: 1000px;
            min-height: 500px;
            margin: 100px auto;
            background-color: #FFFFFF;
            /* border: 1px solid #C80B14;*/
            -moz-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            -webkit-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            /*         box-shadow:0 0 10px #cccccc;
            box-shadow: #cccccc; */
            box-shadow: 0 10px 20px #57a1ff inset, 0 -10px 0 #57a0ff inset;
            padding: 5px;
            text-align: center;
            position: fixed;
            left: 22%;
        }
    </style>
</head>
<body>
<div id="modal-overlay">

</div>
<div class="modal-data1">
    <div style="height: 60px">
        <ul>
            <li style="text-align: left;margin-left: 60px;height: 40px;line-height: 40px">
                <span style="margin-left: 30px;">名称：</span>
                <span>
				  		 	<input class="coachName" type="text">
				  		</span>
                <span>
				  			<button id="findBtnc" class="findBtn2">
				  				查询
				  			</button>
				  		</span>
            </li>
        </ul>
    </div>

    <div style="width:100%; height:350px; overflow:scroll;">
        <form action="">
            <table class="head2" id="personList" style="width: auto;white-space:nowrap;border-spacing: 0px">
                <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
                    <th></th>
                    <th>编码</th>
                    <th>名称</th>
                    <th>身份证号码</th>
                    <th>性别</th>
                    <th>手机号码</th>
                    <th>是否vip教练</th>
                    <th>科目</th>
                    <th>准教证号</th>
                    <th>准教范围</th>
                    <th>教练证有效期开</th>
                    <th>教练证有效期止</th>
                    <th>离职日期</th>
                </tr>

                <c:forEach items="${persons}" var="person" varStatus="s">
                    <tr>
                        <td class="fir"><input class="data1-checkbox" type="checkbox" name="personfid"
                                               style="width: 15px;"
                                               value="${person.fid}"/></td>
                        <td>${person.fnumber}</td>
                        <td>${person.fnameL2}</td>
                        <td>${person.cfidcardno}</td>
                        <c:if test="${person.cfsex==1}">
                            <td>男</td>
                        </c:if>
                        <c:if test="${person.cfsex==2}">
                            <td>女</td>
                        </c:if>
                        <c:if test="${person.cfsex ne 2 && person.cfsex ne 1}">
                            <td>/</td>
                        </c:if>
                        <td>${person.cfcell}</td>
                        <c:if test="${person.cfisvip == 1}">
                            <td><input type="checkbox" checked="checked" checked="checked" value="1"
                                       disabled="disabled"/></td>
                        </c:if>
                        <c:if test="${person.cfisvip == 0}">
                            <td><input type="checkbox" checked="checked" value="0" disabled="disabled"/></td>
                        </c:if>
                        <c:if test="${person.cfkemu eq 1}">
                            <td>科目一</td>
                        </c:if>
                        <c:if test="${person.cfkemu eq 2}">
                            <td>科目二</td>
                        </c:if>
                        <c:if test="${person.cfkemu eq 3}">
                            <td>科目三</td>
                        </c:if>
                        <c:if test="${person.cfkemu == null}">
                            <td></td>
                        </c:if>
                        <td>${person.cfzjzh}</td>
                        <td>${person.cfzjfw}</td>
                        <td>${person.cfjlzyxqs}</td>
                        <td>${person.cfjlzyxqz}</td>
                        <td>${person.cfenddate}</td>
                    </tr>
                </c:forEach>


            </table>

        </form>
    </div>

    <div class="page" style="display: none;">
        <ul style="border-bottom: none;">
            <li>
                <span class="indexPage1">首页</span>
                <span class="prevPage1">上一页</span>
                <span class="nextPage1">下一页</span>
                <span class="endPage1">尾页</span>
                <input type="hidden" id="totalPage1" value="${pb1}">
                <input type="hidden" id="index1" value="0">
            </li>
        </ul>
    </div>

    <button class="subtn1" id="subtn1" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;left: 250px">
        确定
    </button>
    <button class="btn" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;right: 250px">
        关闭
    </button>


</div>
</body>
<script type="text/javascript" src="<%=path3%>/JQuery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<%=path3%>/HoganJS/handlebars-v4.0.11.js"></script>
<script id="table-template-coach" type="text/x-handlebars-template">
    {{#isNull sList}}
    <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
        <th style="width: 20px"></th>
        <th>编码</th>
        <th>名称</th>
        <th>身份证号码</th>
        <th>性别</th>
        <th>手机号码</th>
        <th>是否vip教练</th>
        <th>科目</th>
        <th>准教证号</th>
        <th>准教范围</th>
        <th>教练证有效期开</th>
        <th>教练证有效期止</th>
        <th>离职日期</th>
    </tr>
    {{#each sList}}
    <tr>
        <td class="fir"><input class="data1-checkbox" type="checkbox" value="{{fid}}" name="personfid"/></td>
        <td>{{fnumber}}</td>
        <td>{{fnameL2}}</td>
        <td>{{cfidcardno}}</td>
        {{#compare cfsex 1}}
        <td>男</td>
        {{/compare}}
        {{#compare cfsex 2}}
        <td>女</td>
        {{/compare}}
        {{#compare cfsex 0}}
        <td></td>
        {{/compare}}
        <td>{{cfcell}}</td>
        {{#isNull1 cfisvip}}
        {{#compare cfisvip 1}}
        <td><input type="checkbox" checked="checked" checked="checked" value="1"
                   disabled="disabled"/></td>
        {{/compare}}
        {{#compare cfisvip 0}}
        <td><input type="checkbox" checked="checked" value="0" disabled="disabled"/></td>
        {{/compare}}
        {{else}}
        <td><input type="checkbox" checked="checked" checked="checked" value="1"
                   disabled="disabled"/></td>
        {{/isNull1}}
        {{#isNull1 cfkemu}}
        {{#compare cfkemu 1}}
        <td>科目一</td>
        {{/compare}}
        {{#compare cfkemu 2}}
        <td>科目二</td>
        {{/compare}}
        {{#compare cfkemu 3}}
        <td>科目三</td>
        {{/compare}}
        {{else}}
        <td></td>
        {{/isNull1}}
        <td>{{cfzjzh}}</td>
        <td>{{cfzjfw}}</td>
        <td>{{cfjlzyxqs}}</td>
        <td>{{cfjlzyxqz}}</td>
        <td>{{cfenddate}}
    </tr>
    {{/each}}
    {{else}}
    <td>没有搜索到您想要的内容!</td>
    {{/isNull}}

</script>
<script>
    //弹出框模版文件
    var myTemplatecoach1 = Handlebars.compile($("#table-template-coach").html());

    var coachName = $('.coachName').val();

    //注册一个比较内容是否为空
    Handlebars.registerHelper("isNull", function (v1, options) {
        if (v1 != "") {
            //满足添加继续执行
            return options.fn(this);
        } else {
            //不满足条件执行{{else}}部分
            return options.inverse(this);
        }
    });
    //注册一个比较内容是否为空
    Handlebars.registerHelper("isNull1", function (v1, options) {
        if (v1 != null) {
            //满足添加继续执行
            return options.fn(this);
        } else {
            //不满足条件执行{{else}}部分
            return options.inverse(this);
        }
    });

    //注册一个比较大小的Helper,判断v1是否大于v2
    Handlebars.registerHelper("compare", function (v1, v2, options) {
        if (v2 == 100) {
            //满足添加继续执行
            return options.fn(this);
        }
        if (v1 == v2) {
            //满足添加继续执行
            return options.fn(this);
        } else {
            //不满足条件执行{{else}}部分
            return options.inverse(this);
        }
    });

    //点击查找按钮
    $('#findBtnc').click(function () {
        coachName = $('.coachName').val();
        var index = 0;
        $('#personList').html("<div class='loading'></div>");
        $.ajax({
            url: '<%=path3%>/DrivingSys/getPageAsJl',
            type: "post",
            data: {
                'pindex': '0',
                'name': coachName,
            },
            dataType: "json",
            success: function (res) {
                $('#personList').html(myTemplatecoach1(res));
                $('#totalPage1').val(res.pb);
            },
            error: function () {
                alert('Error');
            }
        });

    })

    $('.indexPage1').click(function () {
        var index = 0
        coachName = $('.coachName').val();
        $('#index1').val(0)
        $.ajax({
            url: '<%=path3%>/DrivingSys/getPageAsJl',
            type: "post",
            data: {
                'pindex': index,
                'name': coachName,
            },
            dataType: "json",
            success: function (json) {
                $('#personList').html(myTemplatecoach1(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.endPage1').click(function () {
        coachName = $('.coachName').val();
        var index = parseInt($('#totalPage1').val())
        $('#index1').val(index)
        $.ajax({
            url: '<%=path3%>/DrivingSys/getPageAsJl',
            type: "post",
            data: {
                'pindex': index,
                'name': coachName,
            },
            dataType: "json",
            success: function (json) {
                $('#personList').html(myTemplatecoach1(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.nextPage1').click(function () {
        coachName = $('.coachName').val();
        var total = parseInt($('#totalPage1').val())
        if ($('#index1').val() < total) {
            var index = $('#index1').val() - 0 + 1
            $('#index1').val(index)
            $.ajax({
                url: '<%=path3%>/DrivingSys/getPageAsJl',
                type: "post",
                data: {
                    'pindex': index,
                    'name': coachName,
                },
                dataType: "json",
                success: function (json) {
                    $('#personList').html(myTemplatecoach1(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经到尾页了！")
        }
    })


    $('.prevPage1').click(function () {
        coachName = $('.coachName').val();
        if ($('#index1').val() != '0') {
            var index = $('#index1').val() - 0 - 1
            $('#index1').val(index)
            $.ajax({
                url: '<%=path3%>/DrivingSys/getPageAsJl',
                type: "post",
                data: {
                    'pindex': index,
                    'name': coachName,
                },
                dataType: "json",
                success: function (json) {
                    $('#personList').html(myTemplatecoach1(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经是首页了")
        }
    })

    //单击选中
    $(document).on('click', '#personList tr td', function () {
        $('.fir input:checkbox:checked').each(function (i) {
            $(this).removeAttr("checked");
        });
        if ($(this).parent().find(".fir input:checkbox").is(':checked')) {
            $(this).parent().find(".fir input:checkbox").removeAttr("checked");
        } else {
            $(this).parent().find(".fir input:checkbox").attr("checked", ":checked")
        }
    })
    //双击
    $(document).on('dblclick', '#personList tr td:not(td:first-child)', function () {
        $(this).parent().find(".fir input:checkbox").attr("checked", ":checked")
        $('#subtn1').click();
    })
</script>
</html>